using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Linq;
using WPFExcelReport.Helpers;
using System.Collections.Generic;
namespace WPFExcelReport
{

    public partial class VICC_WFEVENTS
    {
         
        private string EYGRFB001(Dictionary<string, object> pm)
        {
            string newid = "";
            try
            {
                string events = (string)pm["EVENTID"];
                string MSG = (string)pm["INFO"];
                DataRow dwData = null;
                dwData = TBMain.NewRow();
                SetUpNewRow(ref dwData);
                dwData["ROWNID"] = 0;
                dwData["MANDANT"] = app.Mandant;
                dwData["WFEVENTS"] = Helper.Left(events.PadRight(20), 20);
                dwData["WFWHEN"] = System.DateTime.Now;
                dwData["ORDTYPE"] = "K";

                dwData["CONTROL"] = "   ";
                if (pm.ContainsKey("DEFCONTROL"))
                {
                    dwData["CONTROL"] = (string)pm["DEFCONTROL"];
                }
                dwData["KRS"] = (string)pm["KRS"];
                dwData["LFD"] = (string)pm["LFD"];
                dwData["POS"] = (string)pm["POS"];
                string userid = (string)pm["CUSER"];

                DataRow dwEvents = null;
                var qHander = from DataRow row in TbEventdef.AsEnumerable()
                              where row["WFEVENTS"].ToString().Trim() == events
                              select row;
                foreach (DataRow row in qHander)
                {
                    dwEvents = row;
                }
                var qUsers = from DataRow row in TbScriber.AsEnumerable()
                             where row["WFEVENTS"].ToString().Trim() == events
                             select row;
                foreach (DataRow row in qUsers)
                {
                    newid= INTEXDBC.GetSeq();
                    dwData["ROWNID"] = newid;

                    dwData["USERGROUP"] = row["USERGROUP"];
                    dwData["WFEUSER"] = row["WFEUSER"];
                    dwData["WFEHANDLER"] = dwEvents["WFEHANDLER"];
                    dwData["WHAT"] = Helper.Left(MSG.PadRight(800), 800);
                    dwData["NEWUSER"] = userid;
                    dwData["NEWTIME"] = System.DateTime.Now;
                    InsertICC_WFEVENTS(dwData);
                    //FireEvent(dwWF);
                }
               
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return newid;
        }

    }
}
